package com.ctshk.app.certificate.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.certificate.dto.BusinessDTO;
import com.ctshk.rpc.certificate.dto.BusinessDetailDTO;
import com.ctshk.rpc.certificate.dto.CertificateDTO;
import com.ctshk.rpc.certificate.dto.CertificateInfoDTO;
import com.ctshk.rpc.certificate.req.BusinessHallDescReq;
import com.ctshk.rpc.certificate.req.CertificatePageReq;
import com.ctshk.rpc.certificate.service.ICertificateBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 证件业务 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-19
 */
@Api(value = "证件业务",tags = "证件业务")
@RestController
@RequestMapping("/certificate-business")
public class CertificateBusinessController extends BaseController {

    @DubboReference
    private ICertificateBusinessService certificateBusinessService;

    /**
     1.查询类型为2的可办理业务id列表
     */
    @ApiOperation(value = "首页-證件辦理須知/可预约业务列表", notes = "首页-證件辦理須知/可预约业务列表")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "證件辦理須知", operDesc = "證件辦理須知")
    @PostMapping("/list")
    public Result<PageResponse<CertificateDTO>> queryCertificateList(@RequestBody CertificatePageReq certificateReq) {
        PageResponse<CertificateDTO> response = certificateBusinessService.queryList(certificateReq);
        return Result.success(response);
    }

    /**
        2.可办理业务id查询查询可预约的服务中心
     */
    @ApiOperation(value = "查询可预约的服务中心", notes = "选择预约的服务中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询可预约的服务中心", operDesc = "查询可预约的服务中心")
    @GetMapping(value = "/query-business-hall/{businessId}")
    public Result<List<BusinessDTO>> queryBusinessHall(@PathVariable("businessId") Long businessId) {
        List<BusinessDTO> businessHallList = certificateBusinessService.queryBusinessHall(businessId);
        return Result.success(businessHallList);
    }

    /**
     3.根据可预约中心的id 获取未来一个月的可预约数量等信息
     */
    @ApiOperation(value = "服务中心详情", notes = "服务中心详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "服务中心详情", operDesc = "服务中心详情")
    @PostMapping(value = "/query-business-hall-desc")
    public Result<BusinessDetailDTO> queryBusinessHallDesc(@RequestBody BusinessHallDescReq req) {
        BusinessDetailDTO businessDetailDTO = certificateBusinessService.queryBusinessHallDesc(req);
        return Result.success(businessDetailDTO);
    }


    @ApiOperation(value = "查询辦理須知详情", notes = "查询辦理須知详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询辦理須知详情", operDesc = "查询辦理須知详情")
    @GetMapping(value = "/detail/{id}")
    public Result<CertificateInfoDTO> queryDetail(@PathVariable Long id) {
        return Result.success(certificateBusinessService.queryDetail(id));
    }

}
